package com.CommunityHub.kiana.service;


import com.CommunityHub.kiana.dao.HouseDAO;
import com.CommunityHub.kiana.dao.MemberDAO;
import com.CommunityHub.kiana.dao.UserDAO;
import com.CommunityHub.kiana.dao.VenueDAO;
import com.CommunityHub.kiana.po.*;

import java.sql.SQLException;
import java.util.List;

public class AdminService {
    private UserDAO userDAO = new UserDAO();
    private MemberDAO memberDAO = new MemberDAO();
    private HouseDAO houseDAO = new HouseDAO();
    private VenueDAO venueDAO = new VenueDAO();

    public User login(String username, String password) throws SQLException {
        return userDAO.login(username, password);
    }

    public List<User> getAllUsers() throws SQLException {
        return userDAO.getAllUsers();
    }

    public boolean updateUser(User user) throws SQLException {
        return userDAO.updateUser(user);
    }
    public boolean addUser(User user) throws SQLException {
        return userDAO.addUser(user);
    }
    public boolean deleteUser(int userId) throws SQLException {
        return userDAO.deleteUser(userId);
    }

    public List<MemberDetail> getAllMembers() throws SQLException {
        return memberDAO.getAllMembers();
    }

    public boolean addMember(MemberDetail member) throws SQLException {
        return memberDAO.addMember(member);
    }

    public boolean updateMember(MemberDetail member) throws SQLException {
        return memberDAO.updateMember(member);
    }

    public boolean deleteMember(int memberId) throws SQLException {
        return memberDAO.deleteMember(memberId);
    }

    public List<HouseInfo> getAllHouses() throws SQLException {
        return houseDAO.getAllHouses();
    }
    public boolean addHouse(HouseInfo house) throws SQLException {
        return houseDAO.addHouse(house);
    }
    public boolean updateHouseStatus(int houseId, int status, Integer buyerId, double price) throws SQLException {
        return houseDAO.updateHouseStatus(houseId, status, buyerId, price);
    }

    public List<VenueInfo> getAllVenues() throws SQLException {
        return venueDAO.getAllVenues();
    }

    public boolean addVenue(VenueInfo venue) throws SQLException {
        return venueDAO.addVenue(venue);
    }

    public boolean updateVenue(VenueInfo venue) throws SQLException {
        return venueDAO.updateVenue(venue);
    }

    public boolean deleteVenue(int venueId) throws SQLException {
        return venueDAO.deleteVenue(venueId);
    }

    public boolean updateHouseImage(String buildingNumber, String unitNumber, String roomNumber, String houseImage) throws SQLException {
        return HouseDAO.updateHouseImage(buildingNumber, unitNumber, roomNumber, houseImage);
    }

    public AllCount getAllCount() throws SQLException {
        AllCount allCount = new AllCount();
        int allCountMembers = memberDAO.getAllCountMembers();
        int allCountHouses = houseDAO.getAllCountHouses();
        int allCountVenues = venueDAO.getAllCountVenues();
        int allCountUsers = userDAO.getAllCountUsers();
        allCount.setMember_count(allCountMembers);
        allCount.setHouse_count(allCountHouses);
        allCount.setVenue_count(allCountVenues);
        allCount.setUser_count(allCountUsers);
        return allCount;
    }
}